package com.filldream.fastboot.web.controller.common;

import com.filldream.fastboot.base.entity.Area;
import com.filldream.fastboot.base.request.common.area.AreaListSTO;
import com.filldream.fastboot.common.annotation.RepeatRequestAnnotation;
import com.filldream.fastboot.common.entity.R;
import com.filldream.fastboot.core.manager.AreaManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value = "/common/area")
@Api(tags = "国家地区-ctr")
@Slf4j
public class AreaController {

    @Autowired
    private AreaManager areaManager;

    @RepeatRequestAnnotation(checkData = true,overTime = 2)
    @ApiOperation(value = "获取地区",notes = "根据父级ID获取下级地区,不包含地理分区")
    @PostMapping("/getByPId")
    public R<List<Area>> getByPId(@RequestBody AreaListSTO areaListSTO){
        return R.successd(areaManager.getByParentId(areaListSTO));
    }


}
